package com.alorma.views;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;

import com.androidquery.AQuery;

public class CustomImageView extends ImageView {

	private Context ctx;
	private boolean memCache = false;
	private boolean fileCache = false;
	private String url = "";
	
	public CustomImageView(Context context) {
		super(context);
		this.ctx = context;
		this.isInEditMode();
	}

	public CustomImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.isInEditMode();
	}

	public CustomImageView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		this.isInEditMode();
	}

	public void setBackgroundUrl(String url) {
		
		this.url = url;
		
		cargarImagen(url);
	}
	
	public void setMemCache(boolean memCache) {
		this.memCache  = memCache;
	}
	
	public void setFileCache(boolean fileCache) {
		this.fileCache  = fileCache;
	}

	private void cargarImagen(String url) {
		AQuery aQuery = new AQuery(this.ctx);
		aQuery.id(this).image(url, this.memCache, this.fileCache, 0, 0, null,
				AQuery.FADE_IN_NETWORK, 0.0f);
	}
}
